﻿using BDShop.DAL;
using BDShop.Entities;
using System;
using System.Collections.Generic;
using IsolationLevel = System.Transactions.IsolationLevel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BDShop.Business
{
    public class DistrictService
    {
        public static List<District> GetByCityID(int cityID)
        {
            List<District> districts = new List<District>();
            using (var context = new BDShopEntities(IsolationLevel.ReadUncommitted))
            {
                districts = context.Districts.Where(d=>d.CityID==cityID).OrderBy(d=>d.Order).ToList();
            }

            return districts;
        }

        public static District GetByID(int id)
        {
            using (var context = new BDShopEntities(IsolationLevel.ReadUncommitted))
            {
                return context.Districts.Where(d => d.ID == id).FirstOrDefault();
            }

        }
    }
}
